package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/schema/edge"
	"entgo.io/ent/schema/field"
	"github.com/suyuan32/simple-admin-common/orm/ent/mixins"
)

// Ingredient holds the schema definition for the Ingredient entity.
type Ingredient struct {
	ent.Schema
}

// Fields of the Ingredient.
func (Ingredient) Fields() []ent.Field {
	return []ent.Field{
		// 配料名称
		field.String("name").
			Comment("配料名称").
			Unique(). // 配料名称应该是唯一的
			NotEmpty(),
		// 单位
		field.String("unit").
			Comment("单位 (例如: '个', '片', '克')").
			NotEmpty(),
		//数量
		field.Int("value").
			Comment("数量").
			Optional(),
		// 图像
		field.String("image_url").
			Comment("图像 URL").
			Optional(),
	}
}

// Edges of the Ingredient.
func (Ingredient) Edges() []ent.Edge {
	return []ent.Edge{

		edge.To("combo_ingredients", ComboIngredient.Type),
	}
}
func (Ingredient) Mixin() []ent.Mixin {
	return []ent.Mixin{
		mixins.IDMixin{},
	}
}
